/*
 *************************************************************************
 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
 * Version 1.1  with a permitted attribution clause; you may not  use this
 * file except in compliance with the License. You  may  obtain  a copy of
 * the License at http://www.openbravo.com/legal/license.html
 * Software distributed under the License  is  distributed  on  an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific  language  governing  rights  and  limitations
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
 * All portions are Copyright (C) 2008-2014 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************
*/
package com.wms.entity;

import com.mes.data.EmesVendor;

import java.math.BigDecimal;
import java.util.Date;

import org.openbravo.base.structure.ActiveEnabled;
import org.openbravo.base.structure.BaseOBObject;
import org.openbravo.base.structure.ClientEnabled;
import org.openbravo.base.structure.OrganizationEnabled;
import org.openbravo.base.structure.Traceable;
import org.openbravo.model.ad.access.User;
import org.openbravo.model.ad.system.Client;
import org.openbravo.model.common.enterprise.Locator;
import org.openbravo.model.common.enterprise.Organization;
import org.openbravo.model.common.plm.Product;
import org.openbravo.model.common.uom.UOM;
/**
 * Entity class for entity Wms_Return_Goods_Mx (stored in table Wms_Return_Goods_Mx).
 *
 * NOTE: This class should not be instantiated directly. To instantiate this
 * class the {@link org.openbravo.base.provider.OBProvider} should be used.
 */
public class WmsReturnGoodsMx extends BaseOBObject implements Traceable, ClientEnabled, OrganizationEnabled, ActiveEnabled {
    private static final long serialVersionUID = 1L;
    public static final String TABLE_NAME = "Wms_Return_Goods_Mx";
    public static final String ENTITY_NAME = "Wms_Return_Goods_Mx";
    public static final String PROPERTY_ID = "id";
    public static final String PROPERTY_WMSRETURNGOODS = "wmsReturnGoods";
    public static final String PROPERTY_LOCATOR = "locator";
    public static final String PROPERTY_PRODUCT = "product";
    public static final String PROPERTY_QTY = "qty";
    public static final String PROPERTY_UOM = "uom";
    public static final String PROPERTY_BATCHNO = "batchNo";
    public static final String PROPERTY_EMESVENDOR = "emesVendor";
    public static final String PROPERTY_WMSPRODUCTEXTEND = "wmsProductExtend";
    public static final String PROPERTY_CLIENT = "client";
    public static final String PROPERTY_ORGANIZATION = "organization";
    public static final String PROPERTY_ACTIVE = "active";
    public static final String PROPERTY_CREATIONDATE = "creationDate";
    public static final String PROPERTY_CREATEDBY = "createdBy";
    public static final String PROPERTY_UPDATED = "updated";
    public static final String PROPERTY_UPDATEDBY = "updatedBy";
    public static final String PROPERTY_QTYOUT = "qtyOut";
    public static final String PROPERTY_WMSINORDER = "wmsInOrder";
    public static final String PROPERTY_WMSDELIVERY = "wmsDelivery";
    public static final String PROPERTY__COMPUTEDCOLUMNS = "_computedColumns";


    // Computed columns properties, these properties cannot be directly accessed, they need
    // to be read through _commputedColumns proxy. They cannot be directly used in HQL, OBQuery
    // nor OBCriteria. 
    public static final String COMPUTED_COLUMN_STORAGEQTY = "storageQty";

    public WmsReturnGoodsMx() {
        setDefaultValue(PROPERTY_ACTIVE, true);
        setDefaultValue(PROPERTY_CREATIONDATE, new Date());
        setDefaultValue(PROPERTY_UPDATED, new Date());
    }

    @Override
    public String getEntityName() {
        return ENTITY_NAME;
    }

    public String getId() {
        return (String) get(PROPERTY_ID);
    }

    public void setId(String id) {
        set(PROPERTY_ID, id);
    }

    public WmsReturnGoods getWmsReturnGoods() {
        return (WmsReturnGoods) get(PROPERTY_WMSRETURNGOODS);
    }

    public void setWmsReturnGoods(WmsReturnGoods wmsReturnGoods) {
        set(PROPERTY_WMSRETURNGOODS, wmsReturnGoods);
    }

    public Locator getLocator() {
        return (Locator) get(PROPERTY_LOCATOR);
    }

    public void setLocator(Locator locator) {
        set(PROPERTY_LOCATOR, locator);
    }

    public Product getProduct() {
        return (Product) get(PROPERTY_PRODUCT);
    }

    public void setProduct(Product product) {
        set(PROPERTY_PRODUCT, product);
    }

    public BigDecimal getQty() {
        return (BigDecimal) get(PROPERTY_QTY);
    }

    public void setQty(BigDecimal qty) {
        set(PROPERTY_QTY, qty);
    }

    public UOM getUom() {
        return (UOM) get(PROPERTY_UOM);
    }

    public void setUom(UOM uom) {
        set(PROPERTY_UOM, uom);
    }

    public WmsStorageBatch getBatchNo() {
        return (WmsStorageBatch) get(PROPERTY_BATCHNO);
    }

    public void setBatchNo(WmsStorageBatch batchNo) {
        set(PROPERTY_BATCHNO, batchNo);
    }

    public EmesVendor getEmesVendor() {
        return (EmesVendor) get(PROPERTY_EMESVENDOR);
    }

    public void setEmesVendor(EmesVendor emesVendor) {
        set(PROPERTY_EMESVENDOR, emesVendor);
    }

    public WmsProductExtend getWmsProductExtend() {
        return (WmsProductExtend) get(PROPERTY_WMSPRODUCTEXTEND);
    }

    public void setWmsProductExtend(WmsProductExtend wmsProductExtend) {
        set(PROPERTY_WMSPRODUCTEXTEND, wmsProductExtend);
    }

    public Client getClient() {
        return (Client) get(PROPERTY_CLIENT);
    }

    public void setClient(Client client) {
        set(PROPERTY_CLIENT, client);
    }

    public Organization getOrganization() {
        return (Organization) get(PROPERTY_ORGANIZATION);
    }

    public void setOrganization(Organization organization) {
        set(PROPERTY_ORGANIZATION, organization);
    }

    public Boolean isActive() {
        return (Boolean) get(PROPERTY_ACTIVE);
    }

    public void setActive(Boolean active) {
        set(PROPERTY_ACTIVE, active);
    }

    public Date getCreationDate() {
        return (Date) get(PROPERTY_CREATIONDATE);
    }

    public void setCreationDate(Date creationDate) {
        set(PROPERTY_CREATIONDATE, creationDate);
    }

    public User getCreatedBy() {
        return (User) get(PROPERTY_CREATEDBY);
    }

    public void setCreatedBy(User createdBy) {
        set(PROPERTY_CREATEDBY, createdBy);
    }

    public Date getUpdated() {
        return (Date) get(PROPERTY_UPDATED);
    }

    public void setUpdated(Date updated) {
        set(PROPERTY_UPDATED, updated);
    }

    public User getUpdatedBy() {
        return (User) get(PROPERTY_UPDATEDBY);
    }

    public void setUpdatedBy(User updatedBy) {
        set(PROPERTY_UPDATEDBY, updatedBy);
    }

    public BigDecimal getQtyOut() {
        return (BigDecimal) get(PROPERTY_QTYOUT);
    }

    public void setQtyOut(BigDecimal qtyOut) {
        set(PROPERTY_QTYOUT, qtyOut);
    }

    public WmsInOrder getWmsInOrder() {
        return (WmsInOrder) get(PROPERTY_WMSINORDER);
    }

    public void setWmsInOrder(WmsInOrder wmsInOrder) {
        set(PROPERTY_WMSINORDER, wmsInOrder);
    }

    public WmsDelivery getWmsDelivery() {
        return (WmsDelivery) get(PROPERTY_WMSDELIVERY);
    }

    public void setWmsDelivery(WmsDelivery wmsDelivery) {
        set(PROPERTY_WMSDELIVERY, wmsDelivery);
    }

    public BigDecimal getStorageQty() {
        return (BigDecimal) get(COMPUTED_COLUMN_STORAGEQTY);
    }

    public void setStorageQty(BigDecimal storageQty) {
        set(COMPUTED_COLUMN_STORAGEQTY, storageQty);
    }

    public WmsReturnGoodsMx_ComputedColumns get_computedColumns() {
        return (WmsReturnGoodsMx_ComputedColumns) get(PROPERTY__COMPUTEDCOLUMNS);
    }

    public void set_computedColumns(WmsReturnGoodsMx_ComputedColumns _computedColumns) {
        set(PROPERTY__COMPUTEDCOLUMNS, _computedColumns);
    }


    @Override
    public Object get(String propName) {
      if (COMPUTED_COLUMN_STORAGEQTY.equals(propName)) {
        if (get_computedColumns() == null) {
          return null;
        }
        return get_computedColumns().getStorageQty();
      }
    
      return super.get(propName);
    }
}
